import ObjC from "frida-objc-bridge";
import {log} from "./logger"


function safeEnumerateMethods(className:string) {
  if (!ObjC.available) {
    console.log("Objective-C 运行时不可用");
    return;
  }

  const targetClass = ObjC.classes[className];
  if (!targetClass) {
    console.log(`类 ${className} 未找到，可能原因：
      - 类名拼写错误
      - 类尚未加载
      - 目标进程错误`);
    return;
  }

  // 实例方法
  const instanceMethods = targetClass.$ownMethods || [];
  console.log(`实例方法 (${instanceMethods.length}个):`);
  instanceMethods.forEach(m => console.log(`${m}`));

}

// 使用示例
safeEnumerateMethods("UIViewController");

// Interceptor.attach(vulnerClass['- getSecretString:'].implementation, {
//     onLeave(retval) {
//         console.log(retval.toString())
//     }

// });